const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 3002 });

wss.on('connection', function connection(ws) {
    // ws.send("hello")
    wss.clients.add(ws)
  });

wss.broadcast = function broadcast(data) {
    wss.clients.forEach((client) => {
        if (client.readyState === WebSocket.OPEN) {
            client.send(data);
         }
    });

  };
module.exports = wss;